package com.bailian.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.bailian.common.annotation.Log;
import com.bailian.common.core.controller.BaseController;
import com.bailian.common.core.domain.AjaxResult;
import com.bailian.common.enums.BusinessType;
import com.bailian.system.domain.BlWarehouseType;
import com.bailian.system.service.IBlWarehouseTypeService;
import com.bailian.common.utils.poi.ExcelUtil;
import com.bailian.common.core.page.TableDataInfo;

/**
 * 仓库类型Controller
 * 
 * @author bailian
 * @date 2025-08-04
 */
@RestController
@RequestMapping("/system/warehouse_type")
public class BlWarehouseTypeController extends BaseController
{
    @Autowired
    private IBlWarehouseTypeService blWarehouseTypeService;

    /**
     * 查询仓库类型列表
     */
    @PreAuthorize("@ss.hasPermi('system:warehouse_type:list')")
    @GetMapping("/list")
    public TableDataInfo list(BlWarehouseType blWarehouseType)
    {
        startPage();
        List<BlWarehouseType> list = blWarehouseTypeService.selectBlWarehouseTypeList(blWarehouseType);
        return getDataTable(list);
    }

    /**
     * 导出仓库类型列表
     */
    @PreAuthorize("@ss.hasPermi('system:warehouse_type:export')")
    @Log(title = "仓库类型", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BlWarehouseType blWarehouseType)
    {
        List<BlWarehouseType> list = blWarehouseTypeService.selectBlWarehouseTypeList(blWarehouseType);
        ExcelUtil<BlWarehouseType> util = new ExcelUtil<BlWarehouseType>(BlWarehouseType.class);
        util.exportExcel(response, list, "仓库类型数据");
    }

    /**
     * 获取仓库类型详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:warehouse_type:query')")
    @GetMapping(value = "/{typeId}")
    public AjaxResult getInfo(@PathVariable("typeId") Long typeId)
    {
        return success(blWarehouseTypeService.selectBlWarehouseTypeByTypeId(typeId));
    }

    /**
     * 新增仓库类型
     */
    @PreAuthorize("@ss.hasPermi('system:warehouse_type:add')")
    @Log(title = "仓库类型", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BlWarehouseType blWarehouseType)
    {
        return toAjax(blWarehouseTypeService.insertBlWarehouseType(blWarehouseType));
    }

    /**
     * 修改仓库类型
     */
    @PreAuthorize("@ss.hasPermi('system:warehouse_type:edit')")
    @Log(title = "仓库类型", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BlWarehouseType blWarehouseType)
    {
        return toAjax(blWarehouseTypeService.updateBlWarehouseType(blWarehouseType));
    }

    /**
     * 删除仓库类型
     */
    @PreAuthorize("@ss.hasPermi('system:warehouse_type:remove')")
    @Log(title = "仓库类型", businessType = BusinessType.DELETE)
	@DeleteMapping("/{typeIds}")
    public AjaxResult remove(@PathVariable Long[] typeIds)
    {
        return toAjax(blWarehouseTypeService.deleteBlWarehouseTypeByTypeIds(typeIds));
    }
}
